<?php
////////////////////////////
//html头部
/////////////////////////////
function do_html_header($title,$js = '',$css = ''){    
?>
<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
  		<!-- <meta name="viewport" content="width=device-width, initial-scale=1">-->
		<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
        <!-- 新 Bootstrap 核心 CSS 文件 -->
        <link rel="stylesheet" href="../config/css/bootstrap.css" type="text/css">
        <!-- 可选的Bootstrap主题文件（一般不用引入） -->
        <link rel="stylesheet" href="../config/css/bootstrap-theme.min.css" type="text/css">
        <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
        <script src="../config/js/jquery-2.1.1.min.js"></script>
        <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
        <script src="../config/js/bootstrap.min.js"></script>
        <script src="../config/js/mainfns.js"></script>
		<link rel="stylesheet" href="../config/css/font-awesome.min.css">
        <link rel="stylesheet" href="../config/css/main.css">		
		<?php
			if($css != ''){
				echo "<link rel='stylesheet' href='../config/css/$css.css'>";
			}
		?>
        <!--<script type="text/javascript" src="js/show_cart.js"></script>-->
		<?php
			if($js != ''){
				echo "<script type=\"text/javascript\" src=\"../config/js/".$js.".js\"></script>";
			}
		?>
        <title><?php echo $title?></title>
    </head>
    <body>
    <div id="mainbody">
<?php    
}

////////////////////////////
//HTML尾部
/////////////////////
function do_html_footer(){
?>
		</div>
	</body>
</html>
<?php
}

//主页底部导航条
function displayIndexFooterBar(){
?>
<div class='squareFoot'>
	<div class='square text-center'>
		<a href='index.php'><div class='fa fa-home fa-lg fa-fw'></div>
		<div class='footInfo'>首页</div></a>
	</div>
	<div class='message text-center'>
		<div class='fa fa-envelope-o fa-lg fa-fw'></div>
		<div class='footInfo'>消息</div><div class='msg_notice center-block hide'></div>
	</div>
	<div class='submit text-center' data-toggle="modal" data-target="#submitMenu">
		<div class='fa fa-plus fa-2x'></div>
	</div>
	<div class='search text-center'>
		<a href='search.php'><div class='fa fa-search fa-lg fa-fw'></div>
		<div class='footInfo'>搜索</div></a>
	</div>
	<div class='myprofile text-center'>
		<div class='fa fa-user fa-lg fa-fw'></div>
		<div class='footInfo'>我</div>
	</div>
</div>
<?php
}

//展示提交菜单
function displaySubmitMenu(){
?>
<!-- Modal -->
<div class="modal fade" id="submitMenu" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">请选择发布类型</h4>
      </div>
      <div class="modal-body">
			<div class='submitMenu'>
				<div class='publish text-center'>
					<div class="fa fa-pencil fa-2x">
					</div><div class='info'>发帖</div>
				</div><div class='oldItem text-center'>
					<div class="fa fa-github fa-2x"></div>
					<div class='info'>卖二手货</div>
				</div><div class='openShop text-center'>
					<div class="fa fa-bank fa-2x"></div>
				<div class='info'>开店</div>
			</div>
		</div>
      </div>
      <div class="modal-footer center-block">
        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
      </div>
    </div>
  </div>
</div>
<?php	
}

//展示首页中的类别
function displayTypes(){
?>
<div class='indexTypes'>
	<div class='street text-center'>
		<a href='street.php'><div class='fa fa-street-view fa-2x fa-fw'></div>
		<div class='idx-info'>去广场</div></a>
	</div><div class='oldChange text-center'>
		<div class='fa fa-shopping-basket fa-2x fa-fw'></div>
		<div class='idx-info'>看二手货</div>
	</div><div class='shops text-center'>
		<div class='fa fa-pied-piper-alt fa-2x fa-fw'></div>
		<div class='idx-info'>逛商铺</div>
	</div>
</div>
<?php
}

//提问的底部导航栏,仅用于提问
function displayAskFooterBar(){
?>
	<div class="askFooterBar">
		<div class="fa fa-keyboard-o fa-lg hideKeyboard"></div>
		<div class="fa fa-photo fa-lg insertPic">
			<input type="file" onchange="fileupload(this)" id="uploadImg"  accept="image/*">
		</div>
	</div>
<?php
}

//展示迷雾
function displayMist(){
?>
	<div class='mist hide'></div>
<?php
}

//展示等待
function displayWait(){
?>
	<div class='waiting text-center hide'>
		<div class='fa fa-spinner fa-spin fa-2x'></div>
		<div class='waitinfo'>请等待...</div>	
	</div>
<?php
}

//展示帖子内容,street页面
function showPostTitleLink($post){
	$id 		= $post->id;
	$count 		= $post->nums;
	$title 		= $post->title;
	$user_id	= $post->user_id;
	$posttime	= $post->update_time;
	$timedif 	= gettimediff($posttime);
	$content	= $post->content;
	@$nickname	= $post->nickname;
	$headSrc    = getuserheadsrc($user_id);
	//var_dump($post);
?>
<a href='showPost.php?postid=<?php echo $id;?>'>
<div class='PostTitleLink' postid='<?php echo $id;?>' 
	id="<?php echo 'postid'.$id;?>" name="<?php echo 'postid'.$id;?>">
	<div class='postUser text-center'>
		<img class='postUserHead' src="<?php echo $headSrc;?>">
	</div><div class='postContent'>
		<div class='postUserNickname'><?php echo $nickname;?></div>
		<div class='postTitle'><?php echo $title;?></div>
		<div class='postcontent'><?php echo $content;?></div>
		<div class='postTime'><?php echo $timedif;?>
			<span class='fa fa-comment-o fa-lg repliesNums'>
				<?php echo $count;?>
			</span>
		</div>
	</div>
</div>
</a>
<?php
}

//展示搜索结果的帖子内容,去除了搜索的content的预览
function showSearchPostTitleLink($post){
	$id 		= $post->id;
	$title 		= $post->title;
	$user_id	= $post->user_id;
	$posttime	= $post->update_time;
	$content	= $post->content;
	@$nickname	= $post->nickname;
	$headSrc    = getuserheadsrc($user_id);
?>
<a href='showPost.php?postid=<?php echo $id;?>'>
<div class='PostTitleLink' postid='<?php echo $id;?>' id="<?php echo 'postid'.$id;?>">
	<div class='postUser text-center'>
		<img class='postUserHead' src="<?php echo $headSrc;?>">
	</div><div class='postContent'>
		<div class='postUserNickname'><?php echo $nickname;?></div>
		<div class='postTitle'><?php echo $title;?></div>
		<div class='postcontent'><?php echo $content;?></div>
		<div class='postTime'><?php echo $posttime;?></div>
	</div>
</div>
</a>
<?php
}


//展示post回复内容
function showPostReply($reply,$showlist = 1){
	$id 		= $reply->id;
	$posts_id 	= $reply->posts_id;
	$user_id	= $reply->user_id;
	$content	= $reply->content;
	$replytime	= $reply->update_time;	
	$timedif 	= gettimediff($replytime);
	@$replyid 	= $reply->replyid;
	@$replyuserid = $reply->replyuserid;
	@$nickname	= $reply->nickname;
	@$replynickname	= $reply->replynickname;
	$headSrc    = getuserheadsrc($user_id);
	if($replynickname || $replyid){			
		if($showlist == 1){
			?>
			<button class='btn btn-xs btn-primary dialoglist'
			userid1='<?php echo $user_id;?>'
			userid2='<?php echo $replyuserid;?>'>
				查看对话
			</button>
			<?php
		}
	}
	
?>
<div class='PostReply' replyid="<?php echo $id;?>" 
	id='reply<?php echo $id;?>' name='reply<?php echo $id;?>' 
	user_id='<?php echo $user_id;?>'>
	<div class='replyUserHead text-center'>
		<img src="<?php echo $headSrc;?>">
	</div><div class='postReplyDiv'>
		<div class='replynickname'>
			<span class='r-nickname'><?php echo $nickname;?></span>
			<?php
				if($replynickname || $replyid){
					echo "   回复了   $replynickname";
				}
			?>
		</div>
		<div class='preplycontent'><?php echo $content;?></div>
		<div class='replytime'><?php echo $timedif;?></div>
	</div>
</div>
<?php

}

//展示进度条
function showprogress(){
?>
<div class="progress hide center-block">
  <div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">
    00%
  </div>
</div>
<?php
}

//展示回复底栏
function displayReplyBar(){
?><div class="replyFooterBar">
	<div class="replyFooterBarDiv">
		<div class='replyInputDiv'>
			<input class='replyinputcontent' placeholder='请输入回复内容'>
		</div>
		<div class='replyBtnDiv text-center'>
			发表
		</div>
	</div>
</div><?php
}

//点击回到顶端
function displayBackToTop(){
?><div class='backToTop text-center fa fa-angle-double-up fa-3x'>
	<div class=''></div>
</div><?php
}

//展示搜索输入条
function displaySearchInputBar(){
?><div class='searchInputBarDiv'>
	<div class='searchInputBar'>
		<div class='search-backBtn' onclick="javascript:history.go(-1);">
			<div class="fa fa-arrow-left fa-lg"></div>
		</div>
		<div class='searchInput'>
			<input class='s-input' onchange="searchIt()" placeholder='请输入关键字搜索'>
		</div>
			<div class='clrBtn hide'>
				<div class='fa fa-close fa-lg'></div>
			</div>
	</div>
</div><?php
}

//展示单个消息,需要区分对应的act，actid，已经被动的type，typeid
function showsinglemessage($message){
	//var_dump($message);
	$act = $message->act;
	switch($act){
		case 'replies':
			displayreplymsg($message);
			break;		
		case 'reply2sb':
			displayreply2sbmsg($message);
			break;
	}
}

//展示的回复帖子的消息 message页面
function displayreplymsg($message){
	$msgid 				= $message->id;
	$replyid 			= $message->actid;
	$replyernickname 	= $message->nickname;
	$replyerid			= $message->user_id;
	$replyerheadsrc 	= getuserheadsrc($replyerid);
	$postid 			= $message->typeid;
	$postdetail 		= getpostdetail($postid);
	$posttitle 			= $postdetail->title;	
	$status 			= $message->status;
	if($status == 2){
		$read = 'eread';
	}
?><a href='showReply.php?replyid=<?php echo $replyid;?>&postid=<?php echo $postid;?>'>
	<div class='sMessageDiv <?php echo @$read;?>' msgid='<?php echo $msgid;?>'
	link='showPost.php?postid=<?php echo $postid;?>#reply<?php echo $replyid;?>'>
		<div class='msgSrcUserHead'>
			<img src='<?php echo $replyerheadsrc;?>'>
		</div>
		<div class='msgContentDiv'>
			<div class='msgIntro'>
				<span><?php echo $replyernickname;?></span>   回复了帖子
			</div>
			<div class='msgTitle'><?php echo $posttitle;?></div>
		</div>
	</div>
</a><?php
}

//展示的回复帖子的消息 message页面
function displayreply2sbmsg($message){
	$msgid 				= $message->id;
	$replyid 			= $message->actid;
	$replyernickname 	= $message->nickname;
	$replyerid			= $message->user_id;
	$replyerheadsrc 	= getuserheadsrc($replyerid);
	$replydetail 		= getreplydetail($replyid);
	$postid 			= $replydetail[1]->info->posts_id;
	$replycontent 		= $replydetail[1]->info->content;
	$postdetail 		= getpostdetail($postid);
	$posttitle 			= $postdetail->title;
	$status 			= $message->status;
	if($status == 2){
		$read = 'eread';
	}
?>
<a href='showReply.php?replyid=<?php echo $replyid;?>&postid=<?php echo $postid;?>'>
	<div class='sMessageDiv <?php echo @$read;?>' msgid='<?php echo $msgid;?>'>
		<div class='msgSrcUserHead'>
			<img src='<?php echo $replyerheadsrc;?>'>
		</div>
		<div class='msgContentDiv'>
			<div class='msgIntro'><span><?php echo $replyernickname;?></span>   回复了该帖中的评论</div>
			<div class='msgTitle'><?php echo $posttitle;?></div>
		</div>
	</div>
</a>
<?php 
}

//展示对话列表的modal
function displayDialogListModal(){
?>
<!-- Modal 对话列表 -->
<div class="modal fade" id="dialoglistmodal" tabindex="-1" role="dialog" aria-labelledby="dialoglistmodal">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h5 class="modal-title" id="dialoglistmodal">对话列表
		<span class='sbnick'></span></h5>
      </div>
      <div class="modal-body">
		<div class="dialoglistcontent"></div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default center-block" data-dismiss="modal">关闭对话列表</button>
      </div>
    </div>
  </div>
</div>
<?php
}


?>